<?php

class BaseDeDatos {

    private static $instance = null;
    private $server;
    private $username;
    private $password;
    private $database;

    private function __construct() {

        $this->server = 'localhost';
        $this->username = 'root';
        $this->password = 'john123';
        $this->database = 'sportsManager';
    }

    public static function getInstance() {

        if (self::$instance == null) {
            self::$instance = new BaseDeDatos();
        }

        return self::$instance;
    }

    public function conectar() {

        $conexion = new mysqli();

        @$conexion->connect($this->server, $this->username, $this->password, $this->database);

        if ($conexion->connect_error) {
            die('Error de conexión: ' . $conexion->connect_error);
        } else {
            return $conexion;
        }
    }

}//fin de la clase Conexion

?>
